let editor = ace.edit("editor");
editor.setTheme("ace/theme/monokai");
editor.session.setMode("ace/mode/javascript");  
editor.setOptions({
  autoScrollEditorIntoView: true, // 自动滚动编辑器视图
  // enableSnippets: false,// 启用代码段
  highlightActiveLine: false,
  readOnly: true,
  displayIndentGuides: false,
  showPrintMargin: true,
  enableSnippets: true,
  maxLines: Infinity,
  // printMarginColumn: 20,
});
editor.session.setUseWrapMode(true);
editor.session.setTabSize(2);
editor.setFontSize(16)
editor.renderer.setShowGutter(false);
editor.setShowPrintMargin(false);
editor.renderer.hideCursor();

// 格式化代码
function formatCode() {
  let session = editor.getSession();
  session.setValue(js_beautify(session.getValue(), {
    indent_size : 2,
    max_preserve_newlines: -1,
    space_before_conditional: true,
    // wrap_line_length: 60,
  }));
}